package com.dycc.attch_componet.view.impl;

import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.dycc.attch_componet.R;
import com.dycc.attch_componet.R2;
import com.dycc.attch_componet.adapter.PicShowAdapter;
import com.dycc.attch_componet.custom.AttachViewPager;
import com.dycc.libary.base.StackActivity;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 附件预览:视频、office、图片、音频
 */
@Route(path = "/attach_f/activity/PhotoShowActivity",name = "图片预览")
public class PhotoShowActivity extends StackActivity {
    public static final String SHOWATTACH = "show_attach";

    @Autowired
    public int index;

    @Autowired
    public ArrayList images;

    @BindView(R2.id.show_viewpager)
    AttachViewPager showViewpager;
    @BindView(R2.id.edit_back_imageview)
    ImageView editBackImageview;
    @BindView(R2.id.show_sign_textview)
    TextView showSignTextview;
    @BindView(R2.id.show_edit_imageview)
    ImageView showEditImageview;
    @BindView(R2.id.show_edit_linearlayout)
    RelativeLayout showEditLinearlayout;
    @BindView(R2.id.activity_attach_show)
    RelativeLayout activityAttachShow;
    @BindView(R2.id.edit_rlayout)
    RelativeLayout editRlayout;

    PicShowAdapter adapter;
    @BindView(R2.id.edit_back_llayout)
    LinearLayout editBackLlayout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_photo_show);
        ButterKnife.bind(this);
    }

    @Override
    protected void initView() {
        if (images == null || images.size() == 0) return;
        adapter = new PicShowAdapter(images, this);
        showSignTextview.setText(index + 1 + "/" + images.size());
        showViewpager.setAdapter(adapter);
        showViewpager.setCurrentItem(index, false);
        showViewpager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            }

            @Override
            public void onPageSelected(int pos) {
                showSignTextview.setText((pos + 1) + "/" + images.size());
            }

            @Override
            public void onPageScrollStateChanged(int state) {
            }
        });
    }

    @Override
    protected void initData() {

    }

    @OnClick({R2.id.edit_back_llayout, R2.id.show_edit_linearlayout})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R2.id.edit_back_llayout:
                break;
            case R2.id.show_edit_linearlayout:
                break;
        }
    }
}
